home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14845 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  54 lines

  1. Path: vixen.cso.uiuc.edu!vjaswal
  2. From: vjaswal@ncsa.uiuc.edu (Vijendra Jaswal)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: STL Implementation
  5. Date: 2 Apr 1996 09:54:44 GMT
  6. Organization: National Center for Supercomputing Applications
  7. Message-ID: <4jqth4$el4@vixen.cso.uiuc.edu>
  8. References: <3158429C.242F@cgsd.com>
  9. NNTP-Posting-Host: xtc.ncsa.uiuc.edu
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. : With STL I would like my class to have a point to a list
  13. : of objects in this class.
  14.  
  15. :    class foo
  16. :     {
  17. :           int a;
  18. :        list<foo> * child_list;
  19. :     };
  20.  
  21. : But the pointer to the list<foo> can not be constructed
  22. : because foo isn't finished being defined yet.
  23.  
  24.  
  25. child_list is a pointer, so the compiler knows everything it needs
  26. to in order to construct it.  But I think you need to forward declare
  27. the type of the pointer.  For templates, you can forward declare as follows...
  28.  
  29. template<class T> class list;
  30.  
  31. I successfuly compiled a program with ONLY the following lines (with IRIX 5.3
  32. using Delta C++).
  33.  
  34. // BEGIN
  35. template<class T> class list;
  36.  
  37. class foo
  38. {
  39.   int a;
  40.   list<foo> * child_list;
  41. };
  42.  
  43.  
  44. main()
  45. {
  46. }
  47. // END
  48.  
  49. --
  50. Vijendra Jaswal
  51. v-jaswal@uiuc.edu
  52. National Center for Supercomputing Applications
  53. University of Illinois, Urbana-Champaign
  54.